import utils from "../common/util.js"

export default {

	// 获取好友列表
	gerFriendList(){
		return new Promise((resolve, reject) => {
			uni.request({
				url: utils.basicUrl + "/chat/friend",
				method: "GET",
				data: {
					userId: uni.getStorageSync("userInfo").id
				},
				header:{
					"satoken":  uni.getStorageSync("userInfo").tokenValue
				},
				success: function(res) {
					if (res.data.code === 20000) {
						resolve(res.data.data)
					} else {
						utils.requestFail(res)
					}
				},
				fail: () => {
					uni.showModal({
						content: "网络错误！",
						showCancel: false
					});
				},
			})
		})
	},
	
	// 获取好友详情
	getFriendInfo(friendId){
		return new Promise((resolve, reject) => {
			uni.request({
				url: utils.basicUrl + "/chat/friend/info",
				method: "POST",
				data: {
					userId: uni.getStorageSync("userInfo").id,
					friendId: friendId
				},
				header:{
					"satoken":  uni.getStorageSync("userInfo").tokenValue
				},
				success: function(res) {
					if (res.data.code === 20000) {
						resolve(res.data.data)
					} else {
						utils.requestFail(res)
					}
				},
				fail: () => {
					uni.showModal({
						content: "网络错误！",
						showCancel: false
					});
				},
			})
		})
		
	},
	
	// 添加好友
	addFriend(frinendId){
		// 发送好友请求
	},
	
	// 搜索好友
	searchFriend(){
		
	},
	
	// 删除好友
	deletFriend(){
		
	}
		
}